import { defineStore } from 'pinia'
import { ref } from 'vue'

// 定义 Store
export const useBaseStore = defineStore(
  'base',
  () => {
    // records数据
    const record = ref('ecmec.com.cn')

    // 设置records数据
    const setRecord = (value) => {
      // console.log(value)
      record.value = value
    }
    // 清空records 数据
    const clearRecord = () => {
      record.value = ''
    }
    // const deleteRecord = (index) => {
    //   records.value.splice(index, 1)
    // }

    // 记得 return
    return {
      record,
      setRecord,
      clearRecord,
    }
  },
  {
    // 网页端配置
    // persist: true,
    // 小程序端配置
    persist: {
      storage: {
        getItem(key) {
          return uni.getStorageSync(key)
        },
        setItem(key, value) {
          return uni.setStorageSync(key, value)
        },
      },
    },
  },
)
